package com.wkhyapp.lm.adapter;

import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wkhyapp.lm.R;
import com.wkhyapp.lm.constant.Constant;
import com.wkhyapp.lm.http.vo.Member;
import com.wkhyapp.lm.utils.ImageLoadUtil;

import java.util.List;

/**
 * Created by Administrator on 2021-10-2.
 */

public class MemberAdapter extends BaseQuickAdapter<Member, BaseViewHolder> {

    public MemberAdapter.callBack mCallBack;

    public MemberAdapter(int layoutResId, List<Member> data ) {
        super(layoutResId, data);

    }

    @Override
    protected void convert(BaseViewHolder helper, final  Member item) {
        ImageView imageView = helper.getView(R.id.memberIv);

        if(item.getHeadImg().startsWith("http")){
            ImageLoadUtil.setRoundImage_Normal(mContext,item.getHeadImg(),8,imageView);
        }else{
            ImageLoadUtil.setRoundImage_Normal(mContext, Constant.DEF_HEAD_2+item.getHeadImg(),8,imageView);
        }


        ImageView lv_iv = helper.getView(R.id.lv_iv);

        if("2".equals(item.getLevelId())){
            lv_iv.setVisibility(View.VISIBLE);
            ImageLoadUtil.setImage_Normal(mContext,R.drawable.lv_hj,lv_iv);
        }else if("3".equals(item.getLevelId())){
            lv_iv.setVisibility(View.VISIBLE);
            ImageLoadUtil.setImage_Normal(mContext,R.drawable.lv_zs,lv_iv);
        }else if("4".equals(item.getLevelId())){
            lv_iv.setVisibility(View.VISIBLE);
            ImageLoadUtil.setImage_Normal(mContext,R.drawable.lv_zz,lv_iv);
        }else if("5".equals(item.getLevelId())){
            lv_iv.setVisibility(View.VISIBLE);
            ImageLoadUtil.setImage_Normal(mContext,R.drawable.lv_zz1,lv_iv);
        }else if("6".equals(item.getLevelId())){
            lv_iv.setVisibility(View.VISIBLE);
            ImageLoadUtil.setImage_Normal(mContext,R.drawable.lv_zz2,lv_iv);
        }else if("7".equals(item.getLevelId())){
            lv_iv.setVisibility(View.VISIBLE);
            ImageLoadUtil.setImage_Normal(mContext,R.drawable.lv_zz3,lv_iv);
        }
        else if("8".equals(item.getLevelId())){
            lv_iv.setVisibility(View.VISIBLE);
            ImageLoadUtil.setImage_Normal(mContext,R.drawable.lv_zz4,lv_iv);
        }
        else if("9".equals(item.getLevelId())){
            lv_iv.setVisibility(View.VISIBLE);
            ImageLoadUtil.setImage_Normal(mContext,R.drawable.lv_zz5,lv_iv);
        }
        else if("10".equals(item.getLevelId())){
            lv_iv.setVisibility(View.VISIBLE);
            ImageLoadUtil.setImage_Normal(mContext,R.drawable.lv_zz6,lv_iv);
        }
        else{
            lv_iv.setVisibility(View.GONE);
        }

        helper.setText(R.id.name_tv,item.getNickname());
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mCallBack.action(item);
            }
        });

    }


    public void  setCallBack(MemberAdapter.callBack callBack){
        this.mCallBack = callBack;
    }


    public interface  callBack{
        void action(Member member);
    }

}
